#!/bin/bash
#Author: Yunyang. shunxiang cao
#Date: 2021年06月21日

## 此脚本用于配置ssh免密登录

echo '
>>> 调用创建秘钥脚本'
/root/caosx/script/ssh_nopassword/ssh_keycreate.exp >> /dev/null 2>&1 
ls -l /root/.ssh/ |grep id

echo 'spawn ssh-keygen 秘钥创建成功'

echo '
>>> 调用传输公钥脚本'
for i in `cat /root/caosx/script/ssh_nopassword/ssh_hosts` #ssh_hosts 里写有其它主机 IP
do
    /root/caosx/script/ssh_nopassword/ssh_keymoving.exp $i >> /dev/null 2>&1
    echo "spawn ssh-copy-id -i $i 秘钥传输成功"
done

